package com.framework.bdf4j.config.job;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;

import com.framework.bdf4j.comm.enums.ScaQuartzEnum;
import com.framework.bdf4j.job.entity.SysJob;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

/**
 * 动态任务工厂
 */
@Slf4j
@DisallowConcurrentExecution
public class ScaQuartzFactory implements Job {

	@Autowired
	private ScaQuartzInvokeFactory scaQuartzInvokeFactory;


	@Override
	@SneakyThrows
	public void execute(JobExecutionContext jobExecutionContext) {
		SysJob sysJob = (SysJob) jobExecutionContext.getMergedJobDataMap().get(ScaQuartzEnum.SCHEDULE_JOB_KEY.getType());
		scaQuartzInvokeFactory.init(sysJob, jobExecutionContext.getTrigger());
	}
}
